<template>
    <h3>登录</h3>
    <table border="1">
        <tr>
            <td>用户名：</td>
            <td><input type="text" v-model="info.LName"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" v-model="info.LPwd"></td>
        </tr>       
        <tr>
            <td colspan="2"><button @click="login">登录</button></td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';

const info = ref({
    LName:'',
    LPwd:''
})

//登录
const login = () => {
    axios.get('http://localhost:8177/api/Money/LoginInfo',{
        params:{
            LName:info.value.LName,
            LPwd:info.value.LPwd
        }
    })
    
    .then(res => {
        if(res.data>0){
            alert("登陆成功");
            location.href="/SaveMoney"
        }
        else if(res.data==-1){
            alert("用户名不存在");
        }
        else if(res.data==-2){
            alert("密码错误");
        }
        else{
            
            alert("登录失败");
        }
    })
}


</script>